package com.ccx.coachsite.ui.manage;

import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;

import com.ccx.coachsite.R;
import com.ccx.coachsite.bus.AddCustomInfo;
import com.ccx.coachsite.bus.InviteInfo;
import com.ccx.coachsite.ui.own.OwerBaseView;
import com.ccx.coachsite.ui.own.OwerMainBase;

public class ManageAddCustomResultView extends OwerBaseView {

	private TextView resultInfo;
	private AddCustomInfo mAddCustomInfo;
	private ListView mList;
	List<InviteInfo> mApp;
	
	public ManageAddCustomResultView(Context context, OwerMainBase superView, Object dataParam) {
		super(context, superView);
		
		mAddCustomInfo = (AddCustomInfo)dataParam;
		resultInfo = (TextView)findViewById(R.id.manage_personal_result_success_label);
		resultInfo.setText("您目前还可以邀请"+mAddCustomInfo.getCanInviteNum()+"个好友");
		mApp = mAddCustomInfo.getInviteList();
		if(mApp != null && mApp.size() > 0)
		{
			mList = (ListView)findViewById(R.id.manage_personal_result_success_list);
			ListCustomAdapter adapter = new ListCustomAdapter();
			mList.setAdapter(adapter);
		}
	}

	class ListCustomAdapter extends BaseAdapter {

		@Override
		public int getCount() {
			return mApp.size();
		}

		@Override
		public Object getItem(int position) {
			return mApp.get(position);
		}

		@Override
		public long getItemId(int position) {
			return position;
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			View view = View.inflate(mContext, R.layout.manage_personal_add_custom_list_item,
					null);
			TextView txtName = (TextView) view
					.findViewById(R.id.manage_custom_list_item_name);
			TextView txtFlow = (TextView) view
					.findViewById(R.id.manage_custom_list_item_flow);

			txtName.setText(mApp.get(position).getInviteName());
			txtFlow.setText(mApp.get(position).getInviteTime());
			return view;
		}
	}
}
